<template>
	<view>
		<template v-for="v in list">
			<view class="bgw">
				<view class="item">
					<view class="flex">
						<view class="flex-1 flex">
							<view class="font-32">
								{{v.name}}
							</view>
						</view>
						<view class="">
							<u-button type="warning" shape="circle" text="检查"
								@click="nav('/pagesA/workflowEdit/workflowEdit?id='+v.id+'&name='+v.name)"
								:disabled="!v.isWrite" :customStyle="btnCustomStyle"></u-button>
						</view>
						<view class="ml15">
							<u-button type="success" shape="circle" text="结果"
								@click="nav('/pagesA/workflowResult/workflowResult?id='+v.id+'&name='+v.name)"
								:disabled="!v.isRead" :customStyle="btnCustomStyle"></u-button>
						</view>
					</view>
				</view>
			</view>
			<view class="blank20"></view>
		</template>


		<nodata v-if="loadingStatus == 'end' && list.length == 0"></nodata>
		<view class="blank30"></view>

	</view>
</template>

<script>
	import {
		sop_review_list
	} from '@/common/api.js';
	import nodata from '@/components/nodata.vue';
	export default {
		data() {
			return {
				role: null,
				userInfo: null,
				list: [],
				loadingStatus: '',
				btnCustomStyle:{
					fontSize:'20px'
				}
			}
		},
		components: {
			nodata
		},
		methods: {
			getData() {
				uni.showLoading({
					title: '加载中'
				});
				this.loadingStatus = 'loading';
				sop_review_list().then((res) => {
					let {
						loc_list,
						sop_review_list,
						read_list,
						write_list
					} = res.result;
					// read_list = [63,64,65];
					// write_list = [63,64,65];
					sop_review_list.forEach(v => {
						v.isRead = read_list.includes(v.id);
						v.isWrite = write_list.includes(v.id);
					})
					this.list = sop_review_list;
				}).catch(() => {
					uni.hideLoading();
				}).finally(() => {
					this.loadingStatus = 'end';
					uni.hideLoading();
					uni.stopPullDownRefresh();
				})
			}
		},
		onLoad() {
			try {
				this.role = this.$store.getters.get_role;
				this.userInfo = this.$store.getters.get_userInfo;
				this.getData();
			} catch (e) {
				uni.reLaunch({
					url: '/pages/login/login'
				});
			}
		},
		onShow() {

		},
	}
</script>

<style lang="scss" scoped>
	/deep/.item {
		padding: 20upx 30upx;
	}
</style>